package com.leather.quan.receiver;

import com.leather.common.toolkits.QinNiuKit;
import com.leather.quan.config.MQConfig;
import com.leather.quan.mapper.QuanMapper;
import com.leather.quan.service.CommentService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class QuanQueneReceiver {

    @Autowired
    private CommentService commentService;

    @Autowired
    private QuanMapper quanMapper;



    @RabbitListener(queues = MQConfig.QUAN_QUENE)
    public void receive(String message) {
        QinNiuKit.deleteImage(message);
    }


    @RabbitListener(queues = MQConfig.COMMENT_QUEUE)
    public void commentReciver(String message) {
        Integer id = Integer.parseInt(message);
        commentService.deleteAllComment(id);
    }

    @RabbitListener(queues = MQConfig.QUAN_COMMENTS)
    public void quanCommentReciver(String message) {
        Integer quanId = Integer.parseInt(message);
        System.out.println("OK的");
        quanMapper.addComments(quanId);
    }

}
